package lambda;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author shentianyu
 * @date 2021-06-15 19:10
 */
public class TestLambda {

    public static void main(String[] args) {
        List<Employee> employees = Arrays.asList(
                new Employee("张三",15,5000.00),
                new Employee("李四",20,6000.00),
                new Employee("王五",30,7000.00),
                new Employee("赵六",40,8000.00),
                new Employee("田七",50,7500.00)
        );
//        List<Employee> employeeList = filterEmployee(employees, (e) -> e.getAge() >= 30);
//        employeeList.forEach(System.out::println);
        employees.stream().filter((e)->e.getAge()>=30).forEach(System.out::println);
        employees.stream().map(Employee::getName).forEach(System.out::println);
    }

    public static List<Employee> filterEmployee(List<Employee> list, MyPredict<Employee> mp){
        List<Employee> emps = new ArrayList<>();
        for (Employee emp:list) {
            if(mp.test(emp)){
                emps.add(emp);
            }
        }
        return emps;
    }

}
